Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@backstage/catalog-model
Advanced tools
Types and validators that help describe the model of a Backstage Catalog
@backstage/catalog-model is a package that provides models and utilities for working with the Backstage catalog. It allows you to define, validate, and manipulate entities within the Backstage ecosystem, such as services, components, and APIs.
Entity Validation
This feature allows you to validate entities against the Backstage catalog model. The `validateEntity` function checks if the provided entity conforms to the expected schema.
const { Entity, validateEntity } = require('@backstage/catalog-model');
const entity = {
apiVersion: 'backstage.io/v1alpha1',
kind: 'Component',
metadata: {
name: 'my-component',
},
spec: {
type: 'service',
lifecycle: 'production',
owner: 'team-a',
},
};
const validationResult = validateEntity(entity);
console.log(validationResult);
Entity Kind and API Version
This feature allows you to check the kind and API version of an entity. The `Entity.isComponent` function checks if the entity is of kind 'Component'.
const { Entity } = require('@backstage/catalog-model');
const entity = {
apiVersion: 'backstage.io/v1alpha1',
kind: 'Component',
metadata: {
name: 'my-component',
},
spec: {
type: 'service',
lifecycle: 'production',
owner: 'team-a',
},
};
console.log(Entity.isComponent(entity)); // true
Entity Relations
This feature allows you to define and manipulate relations between entities. The `relations` field in the entity metadata can be used to specify relationships like ownership.
const { Entity, RELATION_OWNED_BY } = require('@backstage/catalog-model');
const entity = {
apiVersion: 'backstage.io/v1alpha1',
kind: 'Component',
metadata: {
name: 'my-component',
relations: [
{
type: RELATION_OWNED_BY,
target: {
kind: 'Group',
name: 'team-a',
namespace: 'default',
},
},
],
},
spec: {
type: 'service',
lifecycle: 'production',
owner: 'team-a',
},
};
console.log(entity.metadata.relations);
AJV (Another JSON Schema Validator) is a package for validating JSON objects against JSON schemas. It is highly performant and supports JSON Schema draft-07. Compared to @backstage/catalog-model, AJV is more general-purpose and not specifically tailored for Backstage entities.
Joi is a powerful schema description language and data validator for JavaScript. It allows you to define schemas for your data and validate JavaScript objects against these schemas. While Joi is versatile and can be used for various validation tasks, it does not provide the specific entity models and utilities that @backstage/catalog-model offers for Backstage.
Yup is a JavaScript schema builder for value parsing and validation. It is similar to Joi but has a more modern API and is often used with React applications. Like Joi, Yup is a general-purpose validation library and does not include the specific models and utilities for Backstage entities provided by @backstage/catalog-model.
Contains the core model types and validators/policies used by the Backstage catalog functionality.
This package will be imported both by the frontend and backend parts of the catalog, as well as by others that want to consume catalog data.
FAQs
Types and validators that help describe the model of a Backstage Catalog
The npm package @backstage/catalog-model receives a total of 102,228 weekly downloads. As such, @backstage/catalog-model popularity was classified as popular.
We found that @backstage/catalog-model demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.